package com.aiss.ws.activity;

import android.os.Handler;
import android.os.Message;
import android.widget.EditText;
import android.widget.TextView;

import com.aiss.ws.R;
import com.aiss.ws.utils.Command;
import com.aiss.ws.utils.Futil;
import com.aiss.ws.utils.Url;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.ViewById;

import java.util.HashMap;

/**
 * Created by chenqiang on 16/5/17.
 */
@EActivity(R.layout.activity_changeinformation)
public class ChangeInformationActivity extends BaseActivity {

    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);

            if(msg.what==Command.HANDLECODE17){
                showMessage("修改成功");
                finish();
            }

        }
    };

    @ViewById(R.id.title)
    TextView title_tv;

    @ViewById(R.id.edittext)
    EditText editText;

    @Extra
    int type;

    @Extra("")
    String content;

    private String strs [] = {"账号修改","手机号修改","qq修改","地址修改"};

    private String strs_ueky [] = {"postcode","phone","qq","addr"};



    @Click(R.id.back)
    void setBack(){
        finish();
    }

    @AfterViews
    void init(){
        title_tv.setText(strs[type]);
        editText.setText(content);
    }

    /**
     * 确认修改
     */
    @Click(R.id.next_button)
    void next_button(){
        HashMap<String,String> map = new HashMap<>();
        map.put("type","alter");
        map.put("upkey",strs_ueky[type]);
        map.put("upcontent",editText.getText().toString());
        Futil.xutils(Url.INFORMATION,map,handler, Command.HANDLECODE17);
    }




}
